﻿<Window x:Class="MonoSettlers.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:this="clr-namespace:MonoSettlers"
        Title="MonoSettlers Animation Editor 0.1 [UNSTABLE]" 
        xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" xmlns:my="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        MinWidth="1024" MinHeight="700" Closing="Window_Closing">
    <Grid>

        <Grid>
            <Button Content="Create..." Height="23" HorizontalAlignment="Left" Margin="6,6,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
            <Button Content="Open.." Height="23" HorizontalAlignment="Left" Margin="87,6,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
            <Label Content="Directory:" Height="28" HorizontalAlignment="Left" Margin="168,5,0,0" Name="label2" VerticalAlignment="Top" />
            <Label Content="{Binding Library.Directory}" Height="28" HorizontalAlignment="Left" Margin="235,5,0,0" Name="label3" VerticalAlignment="Top" />
        </Grid>

        <Grid Margin="0,35,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200"/>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <GroupBox Header="Library Navigation:" HorizontalAlignment="Stretch" Margin="6,0,0,0" VerticalAlignment="Stretch">
                <Grid>
                    <TabControl>
                        <TabItem Header="Animations">
                            <Grid>
                                <TreeView ItemsSource="{Binding Library.Classes}" Margin="0,30,0,0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" SelectedItemChanged="TreeView_SelectedItemChanged">
                                    <TreeView.ItemContainerStyle>
                                        <Style TargetType="{x:Type TreeViewItem}">
                                            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                                            <Setter Property="FontWeight" Value="Normal" />
                                            <Style.Triggers>
                                                <Trigger Property="IsSelected" Value="True">
                                                    <Setter Property="FontWeight" Value="Bold" />
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TreeView.ItemContainerStyle>

                                    <TreeView.ItemTemplate>
                                        <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                                            <TextBlock Text="{Binding Name}" />
                                        </HierarchicalDataTemplate>
                                    </TreeView.ItemTemplate>
                                </TreeView>
                                <Button Content="Show Library Details" Height="23" HorizontalAlignment="Stretch" Margin="6,4,6,0" Name="BTN_ShowLibraryDetails" VerticalAlignment="Top" Click="BTN_ShowLibraryDetails_Click" />
                            </Grid>
                        </TabItem>

                        <TabItem Header="Audio">
                            <Grid>
                                <Button Content="..." Height="23" HorizontalAlignment="Right" Margin="0,6,6,0" Name="BTN_OpenMusicFile" VerticalAlignment="Top" Width="27" />
                                <TextBox Height="23" HorizontalAlignment="Stretch" Margin="6,6,39,0" Name="EDIT_AudioPath" VerticalAlignment="Top" />
                                <Button Content="Add" Height="23" HorizontalAlignment="Left" Margin="6,66,0,0" Name="BTN_AddAudio" VerticalAlignment="Top" Width="75" Click="BTN_AddAudio_Click" />
                                <Button Content="Remove" Height="23" HorizontalAlignment="Left" Margin="91,66,0,0" Name="BTN_RemoveAudio" VerticalAlignment="Top" Width="75" Click="BTN_RemoveAudio_Click" />
                                <ScrollViewer Margin="0,95,0,35" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Auto">
                                    <ListView HorizontalAlignment="Stretch" Name="LIST_AudioObjects" ItemsSource="{Binding Library.AudioObjects}" VerticalAlignment="Stretch">
                                        <ListView.View>
                                            <GridView>
                                                <GridViewColumn Width="30" Header="Used" DisplayMemberBinding="{Binding UsageCount}" />
                                                <GridViewColumn Width="200" Header="Name" DisplayMemberBinding="{Binding Name}"/>
                                            </GridView>
                                        </ListView.View>
                                    </ListView>
                                </ScrollViewer>
                                <Button Content="Play" Height="23" HorizontalAlignment="Left" Margin="6,0,0,0" Name="BTN_Play" VerticalAlignment="Bottom" Width="75" Click="BTN_Play_Click" />
                                <TextBox Height="23" HorizontalAlignment="Stretch" Margin="50,33,6,0" Name="EDIT_AudioName" VerticalAlignment="Top" Width="116" />
                                <Label Content="Name:" Height="28" HorizontalAlignment="Left" Margin="6,31,0,0" Name="label1" VerticalAlignment="Top" />
                            </Grid>
                        </TabItem>
                    </TabControl>
                </Grid>
            </GroupBox>

            <GridSplitter VerticalAlignment="Stretch" Width="3" Grid.Column="1" HorizontalAlignment="Center"/>

            <Grid Grid.Column="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="350" MinHeight="350"/>
                    <RowDefinition Height="10"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <GroupBox Header="Library Details:" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="GROUP_Details" VerticalAlignment="Stretch">
                    <Grid>
                        <this:Wizard x:Name="WIZARD_Details">
                            <TabItem Name="TAB_LibDetails">
                                <Grid>
                                    <Button Content="Create New Class" Height="23" HorizontalAlignment="Left" Margin="6,137,0,3" Name="BTN_CreateClass" VerticalAlignment="Bottom" Width="130" Click="BTN_CreateClass_Click" />
                                    <Label Content="Statistics:" Height="28" HorizontalAlignment="Left" Margin="6,6,0,0"  VerticalAlignment="Top" />
                                    <Label Content="Class Count:" Height="28" HorizontalAlignment="Left" Margin="27,27,0,0"  VerticalAlignment="Top" />
                                    <Label Content="Animation Set Count:" Height="28" HorizontalAlignment="Left" Margin="27,51,0,0" VerticalAlignment="Top" />
                                    <Label Content="Animation Count:" Height="28" HorizontalAlignment="Left" Margin="27,74,0,0"  VerticalAlignment="Top" />
                                    <Label Content="Frame Count:" Height="28" HorizontalAlignment="Left" Margin="27,99,0,0"  VerticalAlignment="Top" />
                                    <Label Content="New Class Name:" Height="28" HorizontalAlignment="Left" Margin="142,136,0,0" VerticalAlignment="Bottom" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="249,138,0,3" Name="EDIT_NewClassName" VerticalAlignment="Bottom" Width="252" />
                                </Grid>
                            </TabItem>
                            <TabItem Name="TAB_ClassDetails">
                                <Grid>
                                    <Button Content="Create New Animation Set" Height="23" HorizontalAlignment="Left" Margin="6,0,0,6" Name="BTN_CreateSet" VerticalAlignment="Bottom" Width="160" Click="BTN_CreateSet_Click" />
                                    <Label Content="New Set Name:" Height="28" HorizontalAlignment="Left" Margin="172,136,0,0"  VerticalAlignment="Bottom" />
                                    <TextBox Height="23" Margin="269,0,87,3" Name="EDIT_NewSetName" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"  />
                                    <Button Content="Remove This Class" Height="23" HorizontalAlignment="Left" Margin="6,0,0,34" Name="BTN_RemoveClass" VerticalAlignment="Bottom" Width="160" Click="BTN_RemoveClass_Click" />
                                    <RadioButton Content="No Ambient Or Empty Animation Set" IsChecked="{Binding UseNoAmbientOrEmptySet}" Height="16" HorizontalAlignment="Left" Margin="17,11,0,0" VerticalAlignment="Top" />
                                    <RadioButton Content="Ambient Animation Set:" IsChecked="{Binding UseAmbientSet}" Height="16" HorizontalAlignment="Left" Margin="17,41,0,0" VerticalAlignment="Top" />
                                    <RadioButton Content="Empty Animation Set:" IsChecked="{Binding UseEmptySet}" Height="16" HorizontalAlignment="Left" Margin="17,71,0,0" VerticalAlignment="Top" />
                                    <ComboBox Height="23" DisplayMemberPath="Name" ItemsSource="{Binding Sets}" SelectedItem="{Binding AmbientSet}" HorizontalAlignment="Left" Margin="172,37,0,0" VerticalAlignment="Top" Width="146" />
                                    <ComboBox Height="23" DisplayMemberPath="Name" ItemsSource="{Binding Sets}" SelectedItem="{Binding EmptySet}" HorizontalAlignment="Left" Margin="172,67,0,0" VerticalAlignment="Top" Width="146" />
                                    <GroupBox Header="Empty/Ambient:" Name="PANEL_AmbientPreview" HorizontalAlignment="Stretch" Margin="324,0,0,35" VerticalAlignment="Stretch">
                                        <Grid />
                                    </GroupBox>
                                    <Button Content="Rename" Height="23" HorizontalAlignment="Right" Margin="0,0,6,3" Name="BTN_ClassRename" VerticalAlignment="Bottom" Width="75" Click="BTN_ClassRename_Click" />
                                </Grid>
                            </TabItem>
                            <TabItem Name="TAB_AnimSetDetails">
                                <Grid>
                                    <Button Content="Create New Animation" Height="23" HorizontalAlignment="Left" Margin="6,0,0,4" Name="BTN_CreateAnimation" VerticalAlignment="Bottom" Width="160" Click="BTN_CreateAnimation_Click" />
                                    <Label Content="New Animation Name:" Height="28" HorizontalAlignment="Left" Margin="172,136,0,0"  VerticalAlignment="Bottom" />
                                    <TextBox Height="23" HorizontalAlignment="Stretch" Margin="307,0,93,3" Name="EDIT_NewAnimName" VerticalAlignment="Bottom" />
                                    <Label Content="Duration:" Height="28" HorizontalAlignment="Left" Margin="6,6,0,0"  VerticalAlignment="Top" />
                                    <TextBox Height="23" Text="{Binding DurationMillis}" HorizontalAlignment="Left" Margin="123,8,0,0" VerticalAlignment="Top" Width="120" />
                                    <GroupBox Header="Animation Preview:" HorizontalAlignment="Stretch" Margin="249,6,0,35" VerticalAlignment="Stretch">
                                        <!--<this:AnimationPlayer x:Name="AnimSetPlayer"/>-->
                                    </GroupBox>
                                    <Button Content="Remove This Set" Height="23" HorizontalAlignment="Left" Margin="6,0,0,33" Name="BTN_RemoveSet" VerticalAlignment="Bottom" Width="160" Click="BTN_RemoveSet_Click" />
                                    <Button Content="Rename" Height="23" HorizontalAlignment="Right" Margin="0,0,6,4" Name="BTN_RenameSet" VerticalAlignment="Bottom" Width="83" Click="BTN_RenameSet_Click" />
                                </Grid>
                            </TabItem>
                            <TabItem Name="TAB_AnimDetails">
                                <Grid>
                                    <TabControl HorizontalAlignment="Stretch" Margin="249,6,5,0" VerticalAlignment="Stretch">
                                        <TabItem Header="Animation Preview">
                                            <Grid>
                                                <this:AnimationPlayer x:Name="AnimPlayer"/>
                                            </Grid>
                                        </TabItem>
                                        <TabItem Header="Stacks/Plane">
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="*"/>
                                                    <ColumnDefinition Width="200"/>
                                                </Grid.ColumnDefinitions>
                                                
                                                <GroupBox Header="Ambient Snapshot:">
                                                    <Grid Name="PANEL_StackPlaneConfig" MouseLeftButtonDown="PANEL_AnimPreview_MouseDown" MouseMove="PANEL_AnimPreview_MouseMove" MouseLeftButtonUp="PANEL_AnimPreview_MouseUp" MouseRightButtonUp="PANEL_AnimPreview_MouseRightButtonUp">
                                                        <Image Source="{Binding FirstFrame.Source, Converter={StaticResource DrawingBitmapConverter}}" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                                                        <Grid Background="Blue" Opacity="0.5" HorizontalAlignment="Left" VerticalAlignment="Top" Name="PANEL_SizeOverlay" MouseLeftButtonDown="PANEL_AnimPreview_MouseDown" MouseMove="PANEL_AnimPreview_MouseMove" MouseLeftButtonUp="PANEL_AnimPreview_MouseUp" MouseRightButtonUp="PANEL_AnimPreview_MouseRightButtonUp"/>
                                                        <Grid Name="PANEL_ResourceOverlays" MouseLeftButtonDown="PANEL_AnimPreview_MouseDown" MouseMove="PANEL_AnimPreview_MouseMove" MouseLeftButtonUp="PANEL_AnimPreview_MouseUp" MouseRightButtonUp="PANEL_AnimPreview_MouseRightButtonUp"/>
                                                        <Grid Name="PANEL_SizeOverlays" MouseLeftButtonDown="PANEL_AnimPreview_MouseDown" MouseMove="PANEL_AnimPreview_MouseMove" MouseLeftButtonUp="PANEL_AnimPreview_MouseUp" MouseRightButtonUp="PANEL_AnimPreview_MouseRightButtonUp"/>
                                                    </Grid>
                                                </GroupBox>
                                                <GroupBox Grid.Column="1" Header="Resource Stacks:" Name="GROUP_ResourceStacks">
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="*"/>
                                                            <RowDefinition Height="*"/>
                                                        </Grid.RowDefinitions>

                                                        <Grid>
                                                            <Button Content="Remove" Height="23" HorizontalAlignment="Left" Margin="6,6,0,0" Name="BTN_RemoveResource" VerticalAlignment="Top" Width="84" Click="BTN_RemoveResource_Click" />
                                                            <Button Content="Clear" Height="23" HorizontalAlignment="Left" Margin="96,6,0,0" Name="BTN_ClearResources" VerticalAlignment="Top" Width="86" Click="BTN_ClearResources_Click" />
                                                            <ListBox HorizontalAlignment="Stretch" Margin="0,35,0,0" Name="LIST_ResourceStacks" ItemsSource="{Binding AnimClass.ResourceStacks}" VerticalAlignment="Stretch"  />
                                                        </Grid>

                                                        <Grid Grid.Row="1">
                                                            <Button Content="Remove" Height="23" HorizontalAlignment="Left" Margin="6,6,0,0" Name="BTN_RemoveBound" VerticalAlignment="Top" Width="84" Click="BTN_RemoveBound_Click" />
                                                            <Button Content="Clear" Height="23" HorizontalAlignment="Left" Margin="96,6,0,0" Name="BTN_ClearBounds" VerticalAlignment="Top" Width="86" Click="BTN_ClearBoundaries_Click" />
                                                            <ListBox HorizontalAlignment="Stretch" Margin="0,35,0,0" Name="LIST_SolidBoundaries" ItemsSource="{Binding AnimClass.SolidBoundaries}" VerticalAlignment="Stretch"  />
                                                        </Grid>
                                                    </Grid>
                                                </GroupBox>
                                            </Grid>
                                        </TabItem>
                                    </TabControl>
                                    <Label Content="OffsetX:" Height="28" HorizontalAlignment="Left" Margin="6,21,0,0" VerticalAlignment="Top" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="123,23,0,0" Text="{Binding OffsetX}" VerticalAlignment="Top" Width="120" />
                                    <Label Content="OffsetY:" Height="28" HorizontalAlignment="Left" Margin="6,47,0,0" VerticalAlignment="Top" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="123,49,0,0" Text="{Binding OffsetY}" VerticalAlignment="Top" Width="120" />
                                    <CheckBox Content="Is Frozen:" IsChecked="{Binding IsFrozen}" Height="16" HorizontalAlignment="Left" Margin="15,86,0,0"  VerticalAlignment="Top" />
                                    <Button Content="Remove This Animation" Height="23" HorizontalAlignment="Left" Margin="6,0,0,6" Name="BTN_RemoveAnim" VerticalAlignment="Bottom" Width="181" Click="BTN_RemoveAnim_Click" />
                                    <Button Content="Rename:" Height="23" HorizontalAlignment="Left" Margin="7,108,0,0" Name="BTN_RenameAnim" VerticalAlignment="Top" Width="109" Click="BTN_RenameAnim_Click" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="123,108,0,0" Name="EDIT_RenameAnim" VerticalAlignment="Top" Width="120" />
                                    <CheckBox Content="Play Sound:" IsChecked="{Binding PlaySound}" Height="16" HorizontalAlignment="Left" Margin="17,151,0,0"  VerticalAlignment="Top" />
                                    <Label Content="Start Delay:" Height="28" HorizontalAlignment="Left" Margin="35,173,0,0"  VerticalAlignment="Top" />
                                    <ComboBox Height="23" ItemsSource="{Binding Library.AudioObjects}" DisplayMemberPath="Name" SelectedItem="{Binding Sound}" HorizontalAlignment="Left" Margin="123,144,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" />
                                    <TextBox Height="23" Text="{Binding SoundStartDelay}" HorizontalAlignment="Left" Margin="123,173,0,0" VerticalAlignment="Top" Width="120" />
                                    <Label Content="Repeat Delay:" Height="28" HorizontalAlignment="Left" Margin="35,201,0,0" VerticalAlignment="Top" />
                                    <TextBox Height="23" Text="{Binding SoundRepeatDelay}" HorizontalAlignment="Left" Margin="123,201,0,0"  VerticalAlignment="Top" Width="120" />
                                    <CheckBox Content="Repeat" IsChecked="{Binding RepeatSound}" Height="16" HorizontalAlignment="Left" Margin="39,235,0,0" VerticalAlignment="Top" />
                                </Grid>
                            </TabItem>
                        </this:Wizard>
                    </Grid>
                </GroupBox>

                <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" Height="3" VerticalAlignment="Center"/>

                <GroupBox Grid.Row="2" Header="Animation Editor:" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="GROUP_AnimDetails" VerticalAlignment="Stretch">
                    <Grid>
                        <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Hidden" Margin="6,6,0,60">
                            <ListBox ItemsSource="{Binding Frames}" SelectedItem="{Binding FrozenFrame}" Name="LIST_AnimFrames">
                                <ListBox.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel Orientation="Horizontal"/>
                                    </ItemsPanelTemplate>
                                </ListBox.ItemsPanel>

                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Border BorderBrush="Gray" Background="GhostWhite" BorderThickness="1" CornerRadius="4" Margin="5" Padding="5">
                                            <Image Margin="2" Width="100" Height="100" Source="{Binding Source, Converter={StaticResource DrawingBitmapConverter}}" Stretch="Uniform"/>
                                        </Border>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </ScrollViewer>
                        <Button Content="Load Capture" Height="23" HorizontalAlignment="Left" Margin="6,0,0,31" Name="BTN_LoadCapture" VerticalAlignment="Bottom" Width="93" IsEnabled="False" />
                        <Button Content="Clear" Height="23" HorizontalAlignment="Right" Margin="0,0,0,0" Name="BTN_Clear" VerticalAlignment="Bottom" Width="93" Click="BTN_Clear_Click" />
                        <Button Content="Move Left" Height="23" HorizontalAlignment="Left" Margin="6,0,0,6" Name="BTN_MoveLeft" VerticalAlignment="Bottom" Width="93" Click="BTN_MoveLeft_Click" />
                        <Button Content="Move Right" Height="23" HorizontalAlignment="Left" Margin="105,0,0,6" Name="BTN_MoveRight" VerticalAlignment="Bottom" Width="106" Click="BTN_MoveRight_Click" />
                        <Button Content="Minimize Bounds" Height="23" HorizontalAlignment="Left" Margin="105,0,0,31" Name="BTN_MinimizeBounds" VerticalAlignment="Bottom" Width="106" Click="BTN_MinimizeBounds_Click" />
                        <Button Content="Store Atlas PNG" Height="23" HorizontalAlignment="Left" Margin="217,0,0,31" Name="BTN_StoreAtlas" VerticalAlignment="Bottom" Width="106" Click="BTN_StoreAtlas_Click" />
                        <Button Content="Load Atlas PNG" Height="23" HorizontalAlignment="Left" Margin="217,0,0,6" Name="BTN_LoadAtlas" VerticalAlignment="Bottom" Width="106" Click="BTN_LoadAtlas_Click" />
                        <Button Content="Optimized Split" IsEnabled="False" Height="23" HorizontalAlignment="Left" Margin="329,0,0,31" Name="BTN_OptimizedSplit" VerticalAlignment="Bottom" Width="124" />
                        <Button Content="Remove Duplicates" Height="23" HorizontalAlignment="Left" Margin="329,0,0,6" Name="BTN_RemoveDups" VerticalAlignment="Bottom" Width="124" Click="BTN_RemoveDups_Click" />
                        <Button Content="Remove Frame" Height="23" HorizontalAlignment="Left" Margin="459,0,0,31" Name="BTN_RemoveFrame" VerticalAlignment="Bottom" Width="100" Click="BTN_RemoveFrame_Click" />
                    </Grid>
                </GroupBox>
            </Grid>
        </Grid>
    </Grid>
</Window>
